package com.vidmt.api.modules.sys.entity.sub;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.vidmt.api.modules.sys.Enums.LvlType;
import com.vidmt.api.modules.sys.entity.Role;

/**
 * {name:TRY, rights:{ vip:{ during:100000, money:10000 } } }
 * 
 * @author xqs
 *
 */
public class RoleLvl extends Role {
	private static final long serialVersionUID = 1L;

	private LvlType lvltype;
	private Integer iosMoney;
	private Integer money;
	private Long during;

	public static void main(String[] args) {
		Role role = new Role();
		role.setKey("TRY");
		role.setRights("{\"iosMoney\":1,\"money\":1,\"lvltype\":\"TRY\",\"during\":1000}");
		RoleLvl lvl = new RoleLvl(role);
		// lvl.setDuring(1000L);
		// lvl.setLvltype(LvlType.TRY);
		// lvl.setMoney(1);

		System.out.println(JSON.toJSONString(lvl));
	}

	public RoleLvl(Role role) {
		super(role);
		JSONObject json = role.getRights();

		this.during = json.getLong("during");
		this.money = json.getInteger("money");
		this.iosMoney = json.getInteger("iosMoney");
		this.lvltype = LvlType.valueOf(this.getKey());
	}

	public Long getDuring() {
		return during;
	}

	public void setDuring(Long during) {
		this.during = during;
	}

	public LvlType getLvltype() {
		return lvltype;
	}

	public void setLvltype(LvlType lvltype) {
		this.lvltype = lvltype;
	}

	public Integer getIosMoney() {
		return iosMoney;
	}

	public void setIosMoney(Integer iosMoney) {
		this.iosMoney = iosMoney;
	}

	public Integer getMoney() {
		return money;
	}

	public void setMoney(Integer money) {
		this.money = money;
	}

}
